#include <iostream>

using namespace std;

int main()
{
   int a[100],b[100];
    int i,j,n;
    std::cout<<"n=";std::cin>>n;
    for (i=0;i<n;i++)
    {
        std::cout<<"a["<<i<<"]=";std::cin>>a[i];
    }
    i=1;
    do
    {
        //calcul cmmdc
        int s1=a[i];
        int s2=a[i-1];
        while (s1!=s2)
        {
            if (s1>s2) s1=s1-s2;
            else s2=s2-s1;
        }
            //inserez pe pozitia i
            n++;
            for (j=n;j>=i;j--)
            {
                a[j]=a[j-1];
            }
            a[i]=s1;
            i=i+2;
    }
    while (i<n)
    for (i=0;i<n;i++)
    {
        std::cout<<a[i]<<" ";
    }
    return 0;
}
